package org.example.mall.Controller;

import org.example.mall.Pojo.ProductInfo;
import org.example.mall.Pojo.Products;
import org.example.mall.Service.ProductsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/product")
public class ProductsController {
    @Autowired
    private ProductsService pService;
    @GetMapping("/preview")
    public List<Products> getPPreviewList() {
        return pService.getPPreviewInfoList();
    }
    @GetMapping("/previewbypid")
    public  Products getPPreview(@RequestParam("pid") String pid) {
        return pService.getPPreviewInfoByPId(pid);
    }
    @GetMapping("/detail")
    public ProductInfo getPInfo(@RequestParam("pid") String pid) {return pService.getPInfoById(pid);}

}
